Implement POST validators/validator_balances APIs#4872
Merged
michaelsproul merged 4 commits intosigp:unstablefrom Dec 8, 2023
Merged
Implement POST validators/validator_balances APIs#4872michaelsproul merged 4 commits intosigp:unstablefrom
michaelsproul merged 4 commits intosigp:unstablefrom
Conversation
This was referenced Oct 23, 2023
paulhauner
approved these changes
Dec 8, 2023
Member
paulhauner
left a comment
There was a problem hiding this comment.
Nice, simple and valuable!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue Addressed
Some API users want to fetch large chunks of the validator set, and currently do so using the
idparam in the query string. However, query strings are usually subject to length limits on both the client and server side. For Lighthouse, we can't extend the length limit without forking our HTTP server (see #4333 (comment)).Proposed Changes
Bypass the issue of query string limits by adding a POST variant of the
/eth/v1/beacon/states/{state_id}/validatorsmethod. It takes the exact same parameters in a JSON body that looks like this:{ "ids": ["1"], "statuses": ["active"] }Update (Dec 2023): this is part of the beacon API spec now.
Additional Info
I would like the RocketPool analytics tools to use this, as they're currently using individual validator queries and large batches in parallel, which frustrate Lighthouse's state load mechanisms. Even with tree-states, large numbers of parallel queries are hard to deal with, because we have to load the entire state, even if only one validator is required. We have caches, but these typically only take effect after one of the requests completes. In practice this is several thousands times slower than if the end-user just loaded the whole validator set once. However users are (rightly) reluctant to do this, because the size of the JSON response is unwieldy. The best of both worlds is to get all the desired validators (and nothing else) in one request: i.e. using a POST request enabled by this PR.